<%--
  Created by IntelliJ IDEA.
  User: HKemmm
  Date: 2022/3/19
  Time: 23:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head lang="en">
    <meta charset="utf-8"/>
    <title>order</title>
    <link rel="stylesheet" type="text/css" href="/static/css/public.css"/>
    <link rel="stylesheet" type="text/css" href="/static/css/proList.css"/>
    <link rel="stylesheet" type="text/css" href="/static/css/mygxin.css"/>

    <style>
        .orderImg {
            width: 87px;
            height: 87px;
        }
    </style>
</head>
<body>
<!----------------------------------------order------------------>
<div class="head ding">
    <div class="wrapper clearfix">
        <div class="clearfix" id="top">
            <h1 class="fl"><a href="/page/index.jsp"><img src="/static/moban/img/logo/logo.png"/></a></h1>
            <div class="fr clearfix" id="top1">
                <p class="fl">
                    <a href="#" id="login">登录</a>
                    <a href="#" id="reg">注册</a>
                </p>
                <form action="#" method="get" class="fl">
                    <input type="text" placeholder="搜索"/>
                    <input type="button"/>
                </form>
                <div class="btn fl clearfix">
                    <a href="mygxin.html"><img src="/static/img/grzx.png"/></a>
                    <a href="#" class="er1"><img src="/static/img/ewm.png"/></a>
                    <a href="cart.html"><img src="/static/img/gwc.png"/></a>
                    <p><a href="#"><img src="/static/img/smewm.png"/></a></p>
                </div>
            </div>
        </div>
        <ul class="clearfix" id="bott">
            <li><a href="index.html">首页</a></li>
            <li>
                <a href="#">所有商品</a>
                <div class="sList">
                    <div class="wrapper  clearfix">
                        <a href="paint.html">
                            <dl>
                                <dt><img src="/static/img/nav1.jpg"/></dt>
                                <dd>浓情欧式</dd>
                            </dl>
                        </a>
                        <a href="paint.html">
                            <dl>
                                <dt><img src="/static/img/nav2.jpg"/></dt>
                                <dd>浪漫美式</dd>
                            </dl>
                        </a>
                        <a href="paint.html">
                            <dl>
                                <dt><img src="/static/img/nav3.jpg"/></dt>
                                <dd>雅致中式</dd>
                            </dl>
                        </a>
                        <a href="paint.html">
                            <dl>
                                <dt><img src="/static/img/nav6.jpg"/></dt>
                                <dd>简约现代</dd>
                            </dl>
                        </a>
                        <a href="paint.html">
                            <dl>
                                <dt><img src="/static/img/nav7.jpg"/></dt>
                                <dd>创意装饰</dd>
                            </dl>
                        </a>
                    </div>
                </div>
            </li>
            <li>
                <a href="flowerDer.html">装饰摆件</a>
                <div class="sList2">
                    <div class="clearfix">
                        <a href="proList.html">干花花艺</a>
                        <a href="vase_proList.html">花瓶花器</a>
                    </div>
                </div>
            </li>
            <li>
                <a href="decoration.html">布艺软饰</a>
                <div class="sList2">
                    <div class="clearfix">
                        <a href="zbproList.html">桌布罩件</a>
                        <a href="bzproList.html">抱枕靠垫</a>
                    </div>
                </div>
            </li>
            <li><a href="paint.html">墙式壁挂</a></li>
            <li><a href="perfume.html">蜡艺香薰</a></li>
            <li><a href="idea.html">创意家居</a></li>
        </ul>
    </div>
</div>
<div class="order cart mt">
    <!-----------------site------------------->
    <div class="site">
        <p class="wrapper clearfix">
            <span class="fl">订单确认</span>
            <img class="top" src="/static/img/cartTop02.png">
        </p>
    </div>
    <!-----------------orderCon------------------->
    <div class="orderCon wrapper clearfix">
        <div class="orderL fl">
            <!--------h3---------------->
            <h3>收件信息<a href="/address/addressInfo?uid=${sessionScope.User.id}" class="fr">新增地址</a></h3>
            <!--------addres---------------->
            <div class="addres clearfix">


            </div>
            <h3>支付方式</h3>
            <!--------way---------------->
            <div class="way clearfix">
                <img class="on" src="/static/img/way01.jpg">
                <img src="/static/img/way02.jpg">
                <img src="/static/img/way03.jpg">
                <img src="/static/img/way04.jpg">
            </div>
            <h3>选择快递</h3>
            <!--------dis---------------->
            <div class="dis clearfix">
                <span class="on">顺风快递</span>
                <span>百世汇通</span>
                <span>圆通快递</span>
                <span>中通快递</span>
            </div>
        </div>
        <div class="orderR fr">
            <div class="msg">
                <h3>订单内容<a href="/shop/car?id=${sessionScope.User.id}" class="fr">返回购物车</a></h3>
                <!--------ul---------------->
                <c:forEach var="item" items="${orderGoods}">
                    <ul class="clearfix">
                        <li class="fl">
                            <img class="orderImg" src="/myimg/${item.goods.img}">
                        </li>
                        <li class="fl">
                            <p>${item.goods.name}</p>
                            <p>数量：${item.num}</p>
                        </li>
                        <li class="fr">￥${item.goods.price}</li>
                    </ul>
                </c:forEach>

            </div>
            <!--------tips---------------->
            <div class="tips">
                <p><span class="fl">商品金额：</span><span class="fr">￥${money}</span></p>
                <p><span class="fl">运费：</span><span class="fr">免运费</span></p>
            </div>
            <!--------tips count---------------->
            <div class="count tips">
                <p><span class="fl">合计：</span><span class="fr">￥${money}</span></p>
            </div>
            <!--<input type="button" name="" value="去支付"> -->
            <input type="hidden" value="${order.id}" id="oid">
            <input type="hidden" value="${sessionScope.User.id}" id="userId">
            <a class="pay" onclick="pay()">去支付</a>
        </div>
    </div>
</div>
<!--编辑弹框-->
<!--遮罩-->
<%--<div class="mask"></div>--%>
<%--<div class="adddz editAddre">--%>
<%--    <form action="#" method="get">--%>
<%--        <input type="text" placeholder="姓名" class="on"/>--%>
<%--        <input type="text" placeholder="手机号"/>--%>
<%--        <div class="city">--%>
<%--            <select name="">--%>
<%--                <option value="省份/自治区">省份/自治区</option>--%>
<%--            </select>--%>
<%--            <select>--%>
<%--                <option value="城市/地区">城市/地区</option>--%>
<%--            </select>--%>
<%--            <select>--%>
<%--                <option value="区/县">区/县</option>--%>
<%--            </select>--%>
<%--            <select>--%>
<%--                <option value="配送区域">配送区域</option>--%>
<%--            </select>--%>
<%--        </div>--%>
<%--        <textarea name="" rows="" cols="" placeholder="详细地址"></textarea>--%>
<%--        <input type="text" placeholder="邮政编码"/>--%>
<%--        <div class="bc">--%>
<%--            <input type="button" value="保存"/>--%>
<%--            <input type="button" value="取消"/>--%>
<%--        </div>--%>
<%--    </form>--%>
<%--</div>--%>
<!--返回顶部-->
<div class="gotop">
    <a href="cart.html">
        <dl>
            <dt><img src="/static/img/gt1.png"/></dt>
            <dd>去购<br/>物车</dd>
        </dl>
    </a>
    <a href="#" class="dh">
        <dl>
            <dt><img src="/static/img/gt2.png"/></dt>
            <dd>联系<br/>客服</dd>
        </dl>
    </a>
    <a href="mygxin.html">
        <dl>
            <dt><img src="/static/img/gt3.png"/></dt>
            <dd>个人<br/>中心</dd>
        </dl>
    </a>
    <a href="#" class="toptop" style="display: none;">
        <dl>
            <dt><img src="/static/img/gt4.png"/></dt>
            <dd>返回<br/>顶部</dd>
        </dl>
    </a>
    <p>400-800-8200</p>
</div>
<!--footer-->
<div class="footer">
    <div class="top">
        <div class="wrapper">
            <div class="clearfix">
                <a href="#2" class="fl"><img src="/static/img/foot1.png"/></a>
                <span class="fl">7天无理由退货</span>
            </div>
            <div class="clearfix">
                <a href="#2" class="fl"><img src="/static/img/foot2.png"/></a>
                <span class="fl">15天免费换货</span>
            </div>
            <div class="clearfix">
                <a href="#2" class="fl"><img src="/static/img/foot3.png"/></a>
                <span class="fl">满599包邮</span>
            </div>
            <div class="clearfix">
                <a href="#2" class="fl"><img src="/static/img/foot4.png"/></a>
                <span class="fl">手机特色服务</span>
            </div>
        </div>
    </div>
    <p class="dibu">最家家居&copy;2013-2017公司版权所有 京ICP备080100-44备0000111000号<br/>
        违法和不良信息举报电话：188-0130-1238，本网站所列数据，除特殊说明，所有数据均出自我司实验室测试</p>
</div>
<script src="/static/js/jquery-1.12.4.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/js/public.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/js/pro.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/js/user.js" type="text/javascript" charset="utf-8"></script>

<script>
    var uid = $("#userId").val();

    $(function () {
        $.ajax({
            url: "/address/getAddressInfo",
            data: {
                uid: uid
            },
            success: function (data) {
                if (data == null) {
                    alert("未设置收货地址！");
                    location.href = "/address/addressInfo?uid=" + uid;

                } else {
                    var content = "";
                    for (var i = 0; i < data.length; i++) {
                        if (data[i].addreas.isdefault == 1) {
                            content += '<div class="addre fl on" onclick="checkBox(this)">' +
                                '<div class="tit clearfix">' +
                                '<p class="fl">' + data[i].addreas.name +
                                '<span class="default">[默认地址]</span>' +
                                '</p>' +
                                '<p class="fr">' +
                                '<a onclick="delAddress(' + data[i].addreas.id + ')">删除</a>' +
                                '<input type="hidden" class="addressId" value="' + data[i].addreas.id + '">' +
                                '<span>|</span>' +
                                '<a href="/address/addressInfo?uid=' + uid + '" class="edit">编辑</a>' +
                                '</p>' +
                                '</div>' +
                                '<div class="addCon">' +
                                '<p>' + data[i].province + '&nbsp;' + data[i].city + '&nbsp;' + data[i].area + '&nbsp;' + data[i].addreas.address +
                                '</p>' +
                                '<p>' + data[i].addreas.phone + '</p>' +
                                '</div>' +
                                '</div>';
                        } else {
                            content += '<div class="addre fl" onclick="checkBox(this)">' +
                                '<div class="tit clearfix">' +
                                '<p class="fl">' + data[i].addreas.name +
                                '</p>' +
                                '<p class="fr">' +
                                '<a class="setDefault" onclick="setDefault(' + data[i].addreas.id + ')">设为默认</a>' +
                                '<span>|</span>' +
                                '<a onclick="delAddress(' + data[i].addreas.id + ')">删除</a>' +
                                '<input type="hidden" class="addressId" value="' + data[i].addreas.id + '">' +
                                '<span>|</span>' +
                                '<a href="/address/addressInfo?uid=' + uid + '" class="edit">编辑</a>' +
                                '</p>' +
                                '</div>' +
                                '<div class="addCon">' +
                                '<p>' + data[i].province + '&nbsp;' + data[i].city + '&nbsp;' + data[i].area + '&nbsp;' + data[i].addreas.address +
                                '</p>' +
                                '<p>' + data[i].addreas.phone + '</p>' +
                                '</div>' +
                                '</div>';
                        }
                    }

                    $(".addres").html(content);
                }
            }
        });
    })


    function checkBox(t) {
        $(t).siblings(".addre").removeClass("on");
        $(t).addClass("on");
    }


    function setDefault(id) {
        $.ajax({
            url: "/address/setDefault",
            data: {
                id: id,
                uid: uid
            },
            success: function (data) {
                if (data == "ok") {
                    location.reload();
                }
            }
        });
    }

    function delAddress(id) {
        if (confirm("是否删除！")) {
            $.ajax({
                url: "/address/delAddress?id=" + id,
                success: function (response) {
                    if (response == "ok") {
                        alert("删除成功！");
                        location.reload();
                    }
                }
            });
        }
    }


    function pay() {
        var addresId = $(".on").find(".addressId").val();
        var oid = $("#oid").val();

        if (addresId == null) {
            alert("未设置地址！！");
            location.href = "/address/addressInfo?uid=" + uid;
        }

        window.location.href = "/order/pay?id=" + oid + "&addressId=" + addresId;
    }
</script>
</body>
</html>

